package com.wzd.learn.springboot.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.wzd.learn.springboot.persistence.dao.RedPkgStatisticDao;
import com.wzd.learn.springboot.persistence.entity.RedPkgStatistic;
import com.wzd.learn.springboot.service.RedpkgStatisticService;

@Service
public class RedpkgStatisticServiceImpl implements RedpkgStatisticService {
	@Resource
	RedPkgStatisticDao redPkgStatisticDao;

	@Override
	public RedPkgStatistic getById(Long activityId) {
		return redPkgStatisticDao.selectByPrimaryKey(activityId);
	}

	@Override
	@Transactional
	public void batchRecord() throws Exception {
		RedPkgStatistic record = new RedPkgStatistic();
		record.setRedPkgActivityId(10001L);
		redPkgStatisticDao.insertSelective(record);
		int i = 1;
		if (i == 1) {
			throw new RuntimeException("test");
		}
		record.setRedPkgActivityId(10002L);
		redPkgStatisticDao.insertSelective(record);
	}
}
